home *** CD-ROM | disk | FTP | other *** search
- package asp.wizard;
-
- import asp.netobjects.nfx.ui.OrderedListModel;
- import asp.netobjects.nfx.util.ExceptionHandler;
- import asp.netobjects.nfx.util.ExternalError;
- import asp.netobjects.nfx.util.InternalError;
- import asp.netobjects.nfx.wizard.Wizard;
- import asp.netobjects.nfx.wizard.WizardPage;
- import asp.netobjects.nfx.wizard.WizardPageView;
- import asp.wizard.def.DefConnection;
- import com.sun.java.swing.ImageIcon;
- import java.util.Vector;
-
- public class WizardModelSubDbQueryJoin extends WizardModelSub {
- private SubDBQueryData _Data;
- private WizardSubDbQuery _Wizard;
-
- public WizardModelSubDbQueryJoin() {
- super.dmCanFinish = true;
- }
-
- public WizardModelSubDbQueryJoin(Wizard wizard, String bullet, String info, ImageIcon icon, ExceptionHandler handler) {
- super(wizard, bullet, info, icon, handler);
- super.dmCanFinish = true;
- this._Wizard = (WizardSubDbQuery)wizard;
- this._Data = this._Wizard.getData();
- }
-
- public SubDBQueryData getData() {
- return this._Data;
- }
-
- protected WizardPageView getViewSingleInstance() {
- WizardViewSubDbQueryJoin wizard = (WizardViewSubDbQueryJoin)WizardViewSubDbQueryJoin.getInstance();
- return WizardViewSubDbQueryJoin.getInstance();
- }
-
- public WizardPage createNext() {
- return new WizardModelSubDbQueryWhere(this._Wizard, (String)null, (String)null, (ImageIcon)null, (ExceptionHandler)null);
- }
-
- public void validate() throws InternalError, ExternalError {
- super.validate();
- WizardViewSubDbQueryJoin view = (WizardViewSubDbQueryJoin)this.getViewSingleInstance();
-
- try {
- this._Data.getFrom(view.getJoins());
- } catch (Exception e) {
- throw new ExternalError(((Throwable)e).getMessage());
- }
- }
-
- public void updateTableComboBox() {
- WizardViewSubDbQueryJoin view = (WizardViewSubDbQueryJoin)((WizardPage)this).getView();
- OrderedListModel tables = this._Data.getSelectedTables();
- view.setLhsTableComboBoxModel(tables);
- view.setRhsTableComboBoxModel(tables);
- }
-
- public void updateLhsFieldList() {
- WizardViewSubDbQueryJoin view = (WizardViewSubDbQueryJoin)((WizardPage)this).getView();
- OrderedListModel olmFields = new OrderedListModel();
- String selTableName = view.getLhsSelectedTable();
- if (selTableName != null && !selTableName.equals("")) {
- DefConnection dc = ((WizardSubDbQuery)((WizardPage)this).getWizard()).getDefConnection();
- SubDBQueryData.setFields(dc, olmFields, selTableName, (boolean[])null);
- olmFields.setOrdered(true);
- }
-
- view.setLhsFieldListModel(olmFields);
- }
-
- public void updateRhsFieldList() {
- WizardViewSubDbQueryJoin view = (WizardViewSubDbQueryJoin)((WizardPage)this).getView();
- OrderedListModel olmFields = new OrderedListModel();
- String selTableName = view.getRhsSelectedTable();
- if (selTableName != null && !selTableName.equals("")) {
- DefConnection dc = ((WizardSubDbQuery)((WizardPage)this).getWizard()).getDefConnection();
- SubDBQueryData.setFields(dc, olmFields, selTableName, (boolean[])null);
- olmFields.setOrdered(true);
- }
-
- view.setRhsFieldListModel(olmFields);
- }
-
- public void loadView() {
- this.updateTableComboBox();
- this.updateLhsFieldList();
- this.updateRhsFieldList();
- this._Data.removeUnsupportedJoins();
- Vector joins = this._Data.getJoins();
- ((WizardViewSubDbQueryJoin)((WizardPage)this).getView()).setJoins(joins);
- }
-
- public void commit() throws InternalError, ExternalError {
- WizardViewSubDbQueryJoin view = (WizardViewSubDbQueryJoin)this.getViewSingleInstance();
- this._Data.setJoins(view.getJoins());
- }
- }
-